# 883 简单：三维型体投影面积
import numpy as np


def projectionArea(grid) -> int:
    ret, zero = 0, 0

    for i in grid:
        ret += len(i)
        ret += max(i)
        zero += i.count(0)

    grid = np.array(grid)
    for i in np.transpose(grid):
        ret += max(i)

    return ret - zero

    # class Solution:
    #     def projectionArea(self, grid: List[List[int]]) -> int:
    #         xyArea = sum(v > 0 for row in grid for v in row)
    #         yzArea = sum(map(max, grid))
    #         zxArea = sum(map(max, zip(*grid)))  # 注意这里为 O(n) 空间复杂度，改为下标枚举则可以 O(1)
    #         return xyArea + yzArea + zxArea


print(projectionArea([[1, 0], [0, 2]]))
